/**
 * 主界面
 */
module game {

    export class MainUI extends eui.Component {
        public btn2: eui.Image;
        public btn1: eui.Image;
        public btn3: eui.Image;
        public topBtn3: eui.Image;
        public topBtn2: eui.Image;
        public topBtn1: eui.Image;

        public constructor() {
            super();
            this.skinName = "MainUISkin";

            this.btn1.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            BtnTool.btnSMin(this.btn1);
            this.btn2.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick2, this);
            BtnTool.btnSMin(this.btn2);
            this.btn3.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            BtnTool.btnSMin(this.btn3);

            this.topBtn3.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick3, this);
            BtnTool.btnSMin(this.topBtn3);

            this.topBtn1.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick4, this);
            BtnTool.btnSMin(this.topBtn1);

            this.topBtn2.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick5, this);
            BtnTool.btnSMin(this.topBtn2);
        }

        public childrenCreated() {
            super.childrenCreated();
            SoundManager.me.PlayMusicByUrl(1);
        }
        private onClick(e: egret.TouchEvent) {
            game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_SHOP);
        }
        private onClick2(e: egret.TouchEvent) {
            game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_QIANGHUA);
        }


        private onClick3(e: egret.TouchEvent) {
            Global.showWaritPanel();
            egret.setTimeout(() => {
                Global.hideWaritPanel();

            }, this, 1000)
        }

        private onClick4(e: egret.TouchEvent) {
            EffectUtils.showTips("这个是tips", 1);
        }
        private onClick5(e: egret.TouchEvent) {
            SoundManager.me.StopBGM();
        }

        public partAdded(partName: string, instance: any): void {
            super.partAdded(partName, instance);
        }
    }
}